<%@ page import="com.example.ssmlab2.model.Book" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Book Management</title>
    <script>
        function del() {
            return confirm("是否要删除该条记录吗?");
        }
    </script>
</head>
<body>
<center>
    <form action="book" method="post">
        <h1>图书管理页面</h1>
        <table border="1">
            <c:if test="${sessionScope.book[0] eq null}">
                No records
            </c:if>
            <c:if test="${sessionScope.book[0] ne null}">
                <tr>
                    <th>图书编号</th>
                    <th>图书名称</th>
                    <th>出版社</th>
                    <th>图书作者</th>
                    <th>出版时间</th>
                    <th>图书价格</th>
                    <th>图书封面</th>
                    <th colspan="3">操作</th>
                </tr>
            </c:if>
            <c:forEach var="book" items="${sessionScope.book}">
                <tr>
                    <td>${book.id}</td>
                    <td>${book.title}</td>
                    <td>${book.publisher}</td>
                    <td>${book.author}</td>
                    <td>${book.publicationTime}</td>
                    <td>${book.price}</td>
                    <td>${book.cover}</td>
                    <td><a href="/book/queryById/${book.id}">修改</a></td>
                    <td><a href="/book/detail/${book.id}">详情</a></td>
                    <td><a href="/book/removeById/${book.id}" onclick="return del()">删除</a></td>
                </tr>
            </c:forEach>
        </table>
        <p><a href="/user/signOut" style="color-rendering: auto">退出</a></p>
    </form>
</center>

</body>
</html>
